﻿using EMall.Domain;
using System.Text.Json;

namespace EMall.ProductService.Brands
{
    public class Brand : AggregateRoot<int>
    {
        public string Name { get; private set; }
        public string LogoUrl { get; private set; }
        protected Brand() { }
        public Brand(string name, string logoUrl)
        {
            Name = name;
            LogoUrl = logoUrl;
            AddDomainEvent(new EntityCreatedDomainEvent<Brand>(this));
        }
        public void Update(string name, string logoUrl)
        {
            var originJson = JsonSerializer.Serialize(this);
            Name = name;
            LogoUrl = logoUrl;
            AddDomainEvent(new EntityUpdatedDomainEvent<Brand>(originJson, this));
        }
    }
}
